<?php

/**
 * 用户相关接口
 */
namespace Api\Controller;
use Think\Controller;
class NewsController extends ApiBaseController {
	protected $news_model;
	
	function _initialize() {
		$this->news_model = D("Common/News");
	}
		
    function queryNews(){
    	$columnId = I("get.columnId", 1);
    	$news = $this->news_model->where("column_id=$columnId and app_pub=1 and weight>=70")
    	    ->field("news_id,title,subtitle,source,type,cover_image,inner_url,outer_url,top_status,full_status,full_title,full_subtitle,full_cover_image,create_time")
    		->order("refresh_time desc,weight desc")->select();
    	$ReturnData = array();
    	if(!empty($news)){
    		$i = 0;
    		foreach ($news as $item){
    			$ReturnData[$i]['bannerId'] = $item['banner_id'];
    			$ReturnData[$i]['pictureUrl'] = $item['picture_url'];
    			$ReturnData[$i]['type'] = $item['type'];
    			$ReturnData[$i]['linkUrl'] = $item['link_url'];
    			$i += 1;
    		}
    	}
    	
    	$data = array('Success'=>true,
    			'ResultCode'=>'0000',
    			'ReturnData'=>$ReturnData,
    			'Message'=>'查询成功'
    	);
    	$this->ajaxReturn($data);
    }
}

